package com.example.springsecuritydemo.security;

import com.example.springsecuritydemo.credential.SimpleHash;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @author lzy
 * @date 2021-06-24 下午5:02
 */
public class SHA256Util {
    /**
     * 加密算法
     **/
    public static final String HASH_ALGORITHM_NAME = "SHA-256";
    /**
     * 循环次数
     **/
    public static final int HASH_ITERATIONS = 15;

    /**
     * 私有构造器
     **/
    private SHA256Util() {
    }

    /**
     * 执行加密-采用SHA256和盐值加密
     **/
    public static String sha256(String password, String salt) {
        return new SimpleHash(HASH_ALGORITHM_NAME, password, salt, HASH_ITERATIONS).toString();
    }
}
